package cn.edu.cdp.dao;

import cn.edu.cdp.domain.College;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CollegeDao {
    @Select("select college_id collegeId, name, president from college")
    List<College> allCollege();

    @Select("select college_id from college where name=#{collegeName}")
    String getIdByName(String collegeName);

    @Insert("insert into college (college_id, name, president) values (#{collegeId}, #{name}, #{president})")
    void insert(College college);

    @Update("update college set name=#{name}, president=#{president} where college_id=#{collegeId}")
    void update(College college);

    @Delete("delete from college where college_id=#{collegeId}")
    void deleteById(String collegeId);
}
